<%
    session.setAttribute("displayPage", "upload");
    // Redirect if this page is being displayed by itself
    if (request.getServletPath().equals("/upload.jsp")) {
        System.out.println("Current Page is set to upload. Redirect to index.jsp");
        response.sendRedirect("");
    }
%>
<h3>Upload Files</h3>
<form action="FileUpload" enctype="multipart/form-data" method="post">
    Choose a text (Apply Yourself or Official Test Score) data file to upload or
    a zip folder containing relevant .pdf files. Checking if text data files 
    contained information for an existing applicant has been omitted (three 
    person group).<br/><br/>
    <b>Please Note: </b>This operation may take a long time depending on how
    large the chosen file is (Zip files with large amounts of .pdf files in
    particular).<br/><br/>
    <table class="uploadTable">
        <tr>
            <td>Choose program:</td>
            <td>
                <input type="radio" name="program" value="MS" checked/>M.S.<br/>
                <input type="radio" name="program" value="PHD"/>Ph.D<br/>
            </td>
        </tr>
        <tr>
            <td>Choose file to upload:</td>
            <td><input name="file" type="file"/></td>
        </tr>
        <tr><td></td>
            <td><input type="submit" value="Upload File"/></td><td></td>
        </tr>
        <tr>
            <td><strong>
                    <%
                        if (session.getAttribute("uploaded") == null) {
                            out.println("No file was selected.");
                            System.out.println("User has not chosen a file to upload.");
                        } else if (session.getAttribute("uploaded").equals("zip")) {
                            out.println("Zip file uploaded successfully");
                            System.out.println("Zip file uploaded successfully.");
                        } else if (session.getAttribute("uploaded").equals("ots")) {
                            out.println("OTS file uploaded successfully");
                            System.out.println("OTS Data file uploaded");
                        } else if (session.getAttribute("uploaded").equals("ay")) {
                            out.println("AY file uploaded successfully");
                            System.out.println("AY Data file uploaded");
                        } else {
                            out.println("Invalid File Type.");
                            System.out.println("No upload performed. Bad file type.");
                        }
                        session.setAttribute("uploaded", null);
                    %>
                </strong></td>
        </tr>
    </table>
</form>